package com.dzt.cloudreader.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.LinearLayout;

import com.dzt.cloudreader.R;
import com.dzt.cloudreader.adapter.recycler.RecyclerAdapter;
import com.dzt.cloudreader.adapter.recycler.RecyclerHolder;
import com.dzt.cloudreader.interfaces.PerfectClickListener;
import com.dzt.cloudreader.model.PersonBean;
import com.dzt.cloudreader.webview.WebViewActivity;

import java.util.List;

/**
 * Created by M02323 on 2017/12/29.
 */

public class MovieDetailAdapter extends RecyclerAdapter<PersonBean> {

	public MovieDetailAdapter(Context context, List<PersonBean> datas, int layoutId) {
		super(context, datas, layoutId);
	}

	@Override
	public void convert(RecyclerHolder holder, final PersonBean data, int position) {
		holder.setText(R.id.tv_name, data.getName());
		holder.setText(R.id.tv_type, data.getType());
		holder.setImageGlide(R.id.iv_avatar, data.getAvatars().getLarge());
		LinearLayout llItem = holder.findView(R.id.ll_item);
		llItem.setOnClickListener(new PerfectClickListener() {
			@Override
			protected void onNoDoubleClick(View v) {
				if (data != null && !TextUtils.isEmpty(data.getAlt())) {
					WebViewActivity.loadUrl(v.getContext(), data.getAlt(), data.getName());
				}
			}
		});
	}
}
